<template>
	<view class="login">
		<view class="tx">
			<image src="/static/icons/leju-logo.png" mode=""></image>
		</view>

		<view class="inp">
			<view class="top">
				<input type="text" v-model="username">
			</view>
			<view class="down">
				<input type="password" v-model="password">
			</view>
		</view>

		<view class="button" @tap="login" v-if="bl">
			登录
		</view>
		<view class="button" :class="bl == false ? 'act' : ''" v-else>
			<view class="xz">
				<text class="iconfont icon-loading"></text>
			</view>
		</view>

		<view class="text">
			<view @tap="go(1)">找回密码</view>
			<view class="line">
				|
			</view>
			<view @tap="go(0)">
				注册账号
			</view>
		</view>
	</view>
</template>

<script>
	import {
		doLogin,
		getMemberInfo
	} from "@/api/mine/mine.js"
	export default {
		data() {
			return {
				username: "17596496508",
				password: "123456",
				bl: true
			}
		},

		methods: {
			async login() {
				var result = await doLogin({
					username: this.username,
					password: this.password
				});
				uni.setStorageSync("token", result.data.token);
				var userinfo = await getMemberInfo();
				uni.setStorageSync("userInfo", userinfo.data.userInfo);
				this.bl = false;
				uni.showToast({
					title:'登录成功,1S后跳转',
				})
				setTimeout(() => {
					uni.switchTab({
						url: "/pages/mine/mine"
					})
				}, 1000)


			},
			// login() {
			// },
			go(val) {
				if (val == 0) {
					uni.navigateTo({
						url: `/pages/mine/register`
					})
				} else {
					uni.navigateTo({
						url: `/pages/mine/resetpw`
					})
				}


			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/font2/iconfont.css';

	.tx {
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		margin: 100rpx auto;


		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	.xz {
		-webkit-animation: loading 1s infinite ease-in-out;
	}

	.icon-loading {
		font-size: 40rpx;
	}

	.inp {
		// margin: 0 auto;
		padding: 0 70rpx;

		input {
			// background-color: green;
			padding: 32rpx;

			border-radius: 2.5rem;
			margin-top: 24rpx;
			margin-bottom: 24rpx;
			box-shadow: 0 0 20rpx 0 rgb(0, 0, 0 / 5%);

		}
	}

	.button {
		width: 600rpx;
		height: 100rpx;
		border-radius: 50rpx;
		background-color: #354e44;
		color: #fff;
		line-height: 100rpx;
		text-align: center;
		margin: 100rpx auto;
		transition: all .6s;
	}

	.act {
		width: 100rpx;
		border-radius: 100rpx;
	}

	.text {
		display: flex;
		justify-content: center;
		font-size: 14px;
		margin-top: 32px;
		color: rgba(0, 0, 0, .7);
		text-align: center;
		height: 20px;
		line-height: 20px;

		.line {
			margin: 0 20rpx;
		}
	}

	@-webkit-keyframes loading {
		0% {
			-webkit-transform: rotate(0deg);
		}


		100% {
			-webkit-transform: rotate(360deg);
		}
	}
</style>
